<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @package    FeatherPHP
 * @subpackage Components
 * @copyright  Copyright (c) 2006, Julien PORTALIER
 * @link       http://feather.portalier.com
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
 */

require_once APP.'config'.DS.'locales.php';

class LocaleComponent extends Locales
{
	public $lang;
	
	function startup($controller)
	{
		// timezone
		date_default_timezone_set(Config::locale_timezone);
		
		// language
		$this->set(Config::locale_default);
	}
	
	function set($lang)
	{
		$this->lang = $lang;
		
		// sets locale
		putenv("LANG=".$this->locales[$this->lang]);
		setlocale(LC_ALL, $this->locales[$this->lang].'.'.Config::charset);
		setlocale(LC_NUMERIC, 'C');
		
		// initializing gettext ()
		bindtextdomain('messages', APP.'locale'.DS); 
		textdomain('messages');
	}
	
	function get()
	{
		return $this->locales[$this->lang];
	}
}
?>